<template>
  <div>
    <!-- 顶部栏 -->
    <van-sticky>
      <van-nav-bar left-arrow @click-left="onClickLeft">
        <template #right>
          <van-icon
            :name="youLike"
            size="18"
            @click="changeYouLike"
            color="#f5b400"
          />
        </template>
      </van-nav-bar>
    </van-sticky>

    <div class="onefood">
      <div class="outimg">
        <img :src="`/other/pic/${(values.imga || '').split(',')[0]}`" />
      </div>
      <div class="updatetime" v-if="values.updatetime">
        <div class="nth1">
          {{
            values.updatetime.slice(0, 10) +
            " " +
            values.updatetime.slice(12, 19)
          }}
        </div>
        <div class="nth1">作者:{{ values.author }}</div>
      </div>
      <h4 class="foodtitle">{{ values.title }}</h4>
      <div class="foodrate">
        <div>
          <van-rate
            v-model="values.rate"
            color="#f5b400"
            void-color="#f5b400"
            disabled
            disabled-color="#f5b400"
          />
          &nbsp;{{ values.rate }}
        </div>
        <div class="icon">
          <div class="icon_box">
            <img src="../../assets/image/QQ.png" alt="" />
          </div>
          <div class="icon_box">
            <img src="../../assets/image/weixin.png" alt="" />
          </div>
          <div class="icon_box">
            <img src="../../assets/image/weibo.png" alt="" />
          </div>
        </div>
      </div>

      <div class="foodtext">{{ values.maintext }}</div>
      <div v-if="(values.imga || '').split(',')[1]" class="outimg2">
        <img :src="`/other/pic/${(values.imga || '').split(',')[1]}`" />
      </div>
      <div v-if="(values.imga || '').split(',')[2]" class="outimg2">
        <img :src="`/other/pic/${(values.imga || '').split(',')[2]}`" />
      </div>
      <div class="tuijian">
        <h2>-------- Author --------</h2>
        <img src="/other/avatar/01.png" alt="" />
        <img src="/other/avatar/02.jpg" alt="" />
        <img src="/other/avatar/03.jpg" alt="" />
        <div></div>
      </div>
    </div>
  </div>
</template>

<script>
import BottomTabbar from "@/components/BottomTabbar.vue";
export default {
  components: { BottomTabbar },
  data() {
    return {
      values: "",
      youLike: "like-o", //顶部收藏
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    getData() {
      let url = `/recommend/travel_aroundDetail?id=${this.$route.params.id}`;
      this.axios.get(url).then((res) => {
        // console.log(res)
        this.values = res.data.results[0];
      });
    },
    // 点击改变收藏状态
    changeYouLike() {
      if (this.youLike == "like") {
        this.youLike = "like-o";
      } else if (this.youLike == "like-o") {
        this.youLike = "like";
      }
    },
  },
};
</script>

<style lang="scss" scoped>
* {
  box-sizing: border-box;
}
.onefood {
  width: 92vw;
  background-color: #fff;
  border-radius: 3vw;
  margin: 25px auto 0;
  box-sizing: border-box;
  .foodrate {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .icon {
      display: flex;
      justify-content: right;
      width: 40vw;
      text-align: center;
      .icon_box {
        width: 30px;
        height: 30px;
        border-radius: 30%;
        margin: 0 5px;
        // box-shadow: 0 5px 10px rgba($color: #000, $alpha: 0.15);
        display: flex;
        align-items: center;
        img {
          width: 60%;
          display: block;
          margin: 0 auto;
        }
      }
    }
  }

  .updatetime {
    display: flex;
    justify-content: start;
    align-items: center;
    margin: 10px 0 20px;
    .nth1 {
      color: #999;
      font-size: 14px;
      margin-right: 20px;
      line-height: 21px;
      font-family: sans-serifz, Arial, Helvetica;
    }
  }
  .outimg2 {
    text-align: center;
    margin: 10px 0;
    img {
      width: 85%;
      border-radius: 10px;
    }
  }
  h4 {
    margin: 10px 0;
    text-align: left;
    font-size: 24px;
    color: #333;
  }
  div {
    color: gray;
    font-size: 4vw;
  }
  .outimg {
    width: 92vw;
    margin: 0 auto;
    border-radius: 10px;
    img {
      width: 100%;
      border-radius: 20px;
    }
  }
  .foodtext {
    text-align: justify;
    width: 100%;
    padding: 3vw 0;
    color: #666;
    font-size: 14px;
    letter-spacing: 1px;
    text-indent: 28px;
    line-height: 24px;
    font-weight: 500;
    margin: 0 auto;
    font-family: sans-serifz, Arial, Helvetica;
  }
  .tuijian {
    width: 95vw;
    margin: 45px 0 10px;
    text-align: center;
    h2 {
      font-size: 12px;
      letter-spacing: 2px;
      color: #aaa;
      font-weight: 200;
    }
    img {
      width: 40px;
      margin: 5px 10px;
      border-radius: 5px;
    }
  }
}

/*顶部导航栏 */
::v-deep .van-nav-bar__text {
  color: white;
}
::v-deep .van-icon {
  color: #333;
}

.van-nav-bar__left span {
  color: white;
}
.van-nav-bar {
  background-color: #fff;
  // box-shadow: 0 5px 10px rgba($color: #000, $alpha: 0.15);
}
.van-nav-bar .van-icon {
  color: #333;
}

.van-nav-bar__text {
  color: #333;
}
</style>